package com.aiyige.base.db.table;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "AdFile")
public class AdFile implements Parcelable {
    public static final String ID = "id";
    public static final String PARENT_ID = "parentId";
    public static final String PROGRESS_STATUS = "progressStatus";
    public static final String CONTROL_OPTION = "controlOption";
    public static final String CREATE_TIME = "createTime";
    public static final String TOTAL_SIZE = "totalSize";
    public static final String DOWNLOADED_SIZE = "downloadedSize";
    public static final String FILE_REMOTE_URL = "fileRemoteUrl";
    public static final String FILE_LOCAL_URL = "fileLocalUrl";
    public static final String FILE_TYPE = "fileType";
    public static final String ROUTER = "router";
    public static final String DOWNLOAD_TIMESTAMP = "downloadTimestamp";
    public static final String DOWNLOAD_ID = "downloadId";
    @DatabaseField(id = true, columnName = ID)
    String id;
    @DatabaseField(columnName = TOTAL_SIZE)
    long totalSize;
    @DatabaseField(columnName = DOWNLOADED_SIZE)
    long downloadedSize;
    @DatabaseField(columnName = FILE_TYPE)
    int fileType;
    @DatabaseField(columnName = FILE_REMOTE_URL)
    String fileRemoteUrl;
    @DatabaseField(columnName = FILE_LOCAL_URL)
    String fileLocalUrl;
    @DatabaseField(columnName = PARENT_ID)
    String parentId;
    @DatabaseField(columnName = CONTROL_OPTION)
    int controlOption;
    @DatabaseField(columnName = PROGRESS_STATUS)
    int progressStatus;
    @DatabaseField(columnName = CREATE_TIME)
    long createTime;

    @DatabaseField(columnName = ROUTER)
    String router;
    @DatabaseField(columnName = DOWNLOAD_TIMESTAMP)
    long downloadTimestamp;
    @DatabaseField(columnName = DOWNLOAD_ID)
    int downloadId;
    @DatabaseField
    String linkMomentSummary;
    @DatabaseField
    String linkMomentId;
    int fileResId;

    public AdFile() {
    }

    private AdFile(Builder builder) {
        setId(builder.id);
        setTotalSize(builder.totalSize);
        setDownloadedSize(builder.downloadedSize);
        setFileType(builder.fileType);
        setFileRemoteUrl(builder.fileRemoteUrl);
        setFileLocalUrl(builder.fileLocalUrl);
        setParentId(builder.parentId);
        setControlOption(builder.controlOption);
        setProgressStatus(builder.progressStatus);
        setCreateTime(builder.createTime);
        setRouter(builder.router);
        setDownloadTimestamp(builder.downloadTimestamp);
        setDownloadId(builder.downloadId);
        setLinkMomentSummary(builder.linkMomentSummary);
        setLinkMomentId(builder.linkMomentId);
        setFileResId(builder.fileResId);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public long getDownloadedSize() {
        return downloadedSize;
    }

    public void setDownloadedSize(long downloadedSize) {
        this.downloadedSize = downloadedSize;
    }

    public int getFileType() {
        return fileType;
    }

    public void setFileType(int fileType) {
        this.fileType = fileType;
    }

    public String getFileRemoteUrl() {
        return fileRemoteUrl;
    }

    public void setFileRemoteUrl(String fileRemoteUrl) {
        this.fileRemoteUrl = fileRemoteUrl;
    }

    public String getFileLocalUrl() {
        return fileLocalUrl;
    }

    public void setFileLocalUrl(String fileLocalUrl) {
        this.fileLocalUrl = fileLocalUrl;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public int getControlOption() {
        return controlOption;
    }

    public void setControlOption(int controlOption) {
        this.controlOption = controlOption;
    }

    public int getProgressStatus() {
        return progressStatus;
    }

    public void setProgressStatus(int progressStatus) {
        this.progressStatus = progressStatus;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getRouter() {
        return router;
    }

    public void setRouter(String router) {
        this.router = router;
    }

    public long getDownloadTimestamp() {
        return downloadTimestamp;
    }

    public void setDownloadTimestamp(long downloadTimestamp) {
        this.downloadTimestamp = downloadTimestamp;
    }

    public int getDownloadId() {
        return downloadId;
    }

    public void setDownloadId(int downloadId) {
        this.downloadId = downloadId;
    }

    public String getLinkMomentSummary() {
        return linkMomentSummary;
    }

    public void setLinkMomentSummary(String linkMomentSummary) {
        this.linkMomentSummary = linkMomentSummary;
    }

    public String getLinkMomentId() {
        return linkMomentId;
    }

    public void setLinkMomentId(String linkMomentId) {
        this.linkMomentId = linkMomentId;
    }

    public int getFileResId() {
        return fileResId;
    }

    public void setFileResId(int fileResId) {
        this.fileResId = fileResId;
    }

    public static final class Builder {
        private String id;
        private long totalSize;
        private long downloadedSize;
        private int fileType;
        private String fileRemoteUrl;
        private String fileLocalUrl;
        private String parentId;
        private int controlOption;
        private int progressStatus;
        private long createTime;
        private String router;
        private long downloadTimestamp;
        private int downloadId;
        private String linkMomentSummary;
        private String linkMomentId;
        private int fileResId;

        private Builder() {
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder totalSize(long val) {
            totalSize = val;
            return this;
        }

        public Builder downloadedSize(long val) {
            downloadedSize = val;
            return this;
        }

        public Builder fileType(int val) {
            fileType = val;
            return this;
        }

        public Builder fileRemoteUrl(String val) {
            fileRemoteUrl = val;
            return this;
        }

        public Builder fileLocalUrl(String val) {
            fileLocalUrl = val;
            return this;
        }

        public Builder parentId(String val) {
            parentId = val;
            return this;
        }

        public Builder controlOption(int val) {
            controlOption = val;
            return this;
        }

        public Builder progressStatus(int val) {
            progressStatus = val;
            return this;
        }

        public Builder createTime(long val) {
            createTime = val;
            return this;
        }

        public Builder router(String val) {
            router = val;
            return this;
        }

        public Builder downloadTimestamp(long val) {
            downloadTimestamp = val;
            return this;
        }

        public Builder downloadId(int val) {
            downloadId = val;
            return this;
        }

        public Builder linkMomentSummary(String val) {
            linkMomentSummary = val;
            return this;
        }

        public Builder linkMomentId(String val) {
            linkMomentId = val;
            return this;
        }

        public Builder fileResId(int val) {
            fileResId = val;
            return this;
        }

        public AdFile build() {
            return new AdFile(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeLong(this.totalSize);
        dest.writeLong(this.downloadedSize);
        dest.writeInt(this.fileType);
        dest.writeString(this.fileRemoteUrl);
        dest.writeString(this.fileLocalUrl);
        dest.writeString(this.parentId);
        dest.writeInt(this.controlOption);
        dest.writeInt(this.progressStatus);
        dest.writeLong(this.createTime);
        dest.writeString(this.router);
        dest.writeLong(this.downloadTimestamp);
        dest.writeInt(this.downloadId);
        dest.writeString(this.linkMomentSummary);
        dest.writeString(this.linkMomentId);
        dest.writeInt(this.fileResId);
    }

    protected AdFile(Parcel in) {
        this.id = in.readString();
        this.totalSize = in.readLong();
        this.downloadedSize = in.readLong();
        this.fileType = in.readInt();
        this.fileRemoteUrl = in.readString();
        this.fileLocalUrl = in.readString();
        this.parentId = in.readString();
        this.controlOption = in.readInt();
        this.progressStatus = in.readInt();
        this.createTime = in.readLong();
        this.router = in.readString();
        this.downloadTimestamp = in.readLong();
        this.downloadId = in.readInt();
        this.linkMomentSummary = in.readString();
        this.linkMomentId = in.readString();
        this.fileResId = in.readInt();
    }

    public static final Creator<AdFile> CREATOR = new Creator<AdFile>() {
        @Override
        public AdFile createFromParcel(Parcel source) {
            return new AdFile(source);
        }

        @Override
        public AdFile[] newArray(int size) {
            return new AdFile[size];
        }
    };
}
